<?php

require_once '../util/timer.php';
require_once '../db/db.php'; 
require_once '../db/get/thread.php';
require_once '../config.php';
require_once '../util/consts.php';
require_once '../util/Bitter.php';

$_TPL = array();

$stimer = mtimer();
echoThreads();
echo "foo" . mtimer( $stimer );

function echoThreads() {
  global $_TPL;

  $psize = ((int)$_REQUEST['psize'] > 0) ? intval((int)$_REQUEST['psize']) : DEFAULT_THREAD_PAGE_SIZE;
  if( $_REQUEST['uid'] > 0 ) {
    $uid = (int)intval($_REQUEST['uid']);
    $page = ($_REQUEST['page']) ? (int)intval($_REQUEST['page']) : DEFAULT_THREAD_START_PAGE;
  } else {
    die( "BREAKAGE!" ); // BREAKAGE
  }

  $threads = getThreadsByUid( $uid, ($page-1)*$psize, $psize );
  //$count = threadCountByUid($uid);

  for( $i = count($threads)-1; $i > -1; --$i ){ 
    // we need to desmurf all the smurfs, but where? Not in template
   // $threads[$i]['datum'] = smurf($threads[$i]['datum'], $threads[$i]['smurfKey']);
  }  

  $_TPL['uid'] = $uid;
  $_TPL['threads'] = $threads;
//  $_TPL['count'] = $count;
  $_TPL['start'] = $start;
  $_TPL['inc'] = $inc;

  showTpl('Blog');
  //skin_ShowThreads( $fnum, $threads, $count, $start, $inc );

}

?>
